home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0039
/
source
/
dcdprint.mod
< prev
next >
Wrap
Text File
|
1997-04-16
|
12KB
|
369 lines
IMPLEMENTATION MODULE DCDPrintImage;
(*--------------------------------------------------------------------*)
(* *)
(* Run Image Dialog. *)
(* *)
(* This is version 1.00 August 1988 L.G.Miller *)
(* *)
(*--------------------------------------------------------------------*)
(* IMPORT Trace; *)
FROM DCGlobal IMPORT PictureImage,
PrintImage,
HiResMaxX,
HiResMaxY,
BITSPERWORD;
FROM SYSTEM IMPORT ADDRESS, ADR;
FROM Strings IMPORT String, Assign, Concat, Length;
IMPORT Object;
IMPORT Forms;
FROM Forms IMPORT DialAction;
IMPORT M2Conv;
IMPORT GemObjects;
FROM ManyWindows IMPORT
(* VAR *)
AESApplId, (* AES handle for this application *)
VDIHandle, (* VDI handle of current Virtual Workstation *)
ShowMouse,
HideMouse;
FROM Dcrsc IMPORT
dpsize,
dpszpicx,
dpszpicy,
dpszpicw,
dpszpich,
dpszprtx,
dpszprty,
dpszprtw,
dpszprth,
dpszland,
dpszerrm,
dpszcan,
dpszok;
(* -------------------- End of IMPORTS ----------------------- *)
(*----------------------------------------------------------------------*)
(* G L O B A L T Y P E S *)
(*----------------------------------------------------------------------*)
TYPE
StringPtr = POINTER TO String; (* null terminated *)
(*----------------------------------------------------------------------*)
(* Convert a string to a cardinal & check its within a range. *)
(*----------------------------------------------------------------------*)
PROCEDURE StringToCardinal ( min, max : CARDINAL;
VAR text : ARRAY OF CHAR;
VAR card : CARDINAL ) : BOOLEAN;
VAR
done : BOOLEAN;
BEGIN
card := M2Conv.ConvToCard( text );
RETURN ( done AND (( card >= min ) AND ( card <= max )) );
END StringToCardinal;
(*----------------------------------------------------------------------*)
(* Convert a cardinal to a string with a given width ( length? ) *)
(*----------------------------------------------------------------------*)
PROCEDURE CardinalToString ( n, width : CARDINAL;
VAR text : ARRAY OF CHAR );
BEGIN
M2Conv.CardToString( n, width, text );
END CardinalToString;
(*----------------------------------------------------------------------*)
(* Put given print image info into dialog. *)
(*----------------------------------------------------------------------*)
PROCEDURE PrintImageToDialog ( VAR printinfo : PrintImage );
VAR str : String;
BEGIN
CardinalToString( printinfo.StartCharX, 3, str ); (* x co-ord *)
GemObjects.SetTEDData( dpsize, dpszprtx, str );
GemObjects.DeselectObject( dpsize, dpszprtx );
CardinalToString( printinfo.StartCharY, 3, str ); (* y co-ord *)
GemObjects.SetTEDData( dpsize, dpszprty, str );
GemObjects.DeselectObject( dpsize, dpszprty );
CardinalToString( printinfo.Width, 4, str ); (* width *)
GemObjects.SetTEDData( dpsize, dpszprtw, str );
GemObjects.DeselectObject( dpsize, dpszprtw );
CardinalToString( printinfo.Height, 4, str ); (* Height *)
GemObjects.SetTEDData( dpsize, dpszprth, str );
GemObjects.DeselectObject( dpsize, dpszprth );
str := 'N';
IF printinfo.QueryLandscapePrint THEN str := 'Y' END;
GemObjects.SetTEDData( dpsize, dpszland, str );
GemObjects.DeselectObject( dpsize, dpszland );
END PrintImageToDialog;
(*----------------------------------------------------------------------*)
(* Print info from dialog to print image record. Hilight errors *)
(*----------------------------------------------------------------------*)
PROCEDURE DialogToPrintImage ( VAR printinfo : PrintImage;
VAR errormsg : ARRAY OF CHAR ) : BOOLEAN;
(* true = ok *)
VAR str : String;
done, error : BOOLEAN;
i : CARDINAL;
BEGIN
error := FALSE;
errormsg[0] := 0C;
GemObjects.GetTEDData( dpsize , dpszprtx, str );
IF NOT StringToCardinal( 0, 75, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszprtx );
IF errormsg[0] = 0C THEN
Assign( 'Print: x ( 0 .. 75 ) ',errormsg);
END;
ELSE
printinfo.StartCharX := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszprty, str );
IF NOT StringToCardinal( 0, 75, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszprty );
IF errormsg[0] = 0C THEN
Assign( 'Print: y ( 0 .. 75 ) ',errormsg);
END;
ELSE
printinfo.StartCharY := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszprtw, str );
IF NOT StringToCardinal( 0, 3000, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszprtw );
IF errormsg[0] = 0C THEN
Assign( 'Print: width (0 .. 3000)', errormsg);
END;
ELSE
printinfo.Width := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszprth, str );
IF NOT StringToCardinal( 0, 3000, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszprth );
IF errormsg[0] = 0C THEN
Assign( 'Print: height (0 .. 3000)', errormsg);
END;
ELSE
printinfo.Height := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszland, str );
str[0] := CAP(str[0]);
IF str[0] # 'Y' THEN str[0] := 'N' END;
printinfo.QueryLandscapePrint := ( str[0] = 'Y' );
GemObjects.SetTEDData( dpsize, dpszland, str );
GemObjects.DeselectObject( dpsize, dpszland );
RETURN NOT error;
END DialogToPrintImage;
(*----------------------------------------------------------------------*)
(* Put given picture image info into dialog. *)
(*----------------------------------------------------------------------*)
PROCEDURE PictureImageToDialog ( VAR pictureinfo : PictureImage );
VAR str : String;
BEGIN
CardinalToString( pictureinfo.StartX, 3, str ); (* x co-ord *)
GemObjects.SetTEDData( dpsize, dpszpicx, str );
GemObjects.DeselectObject( dpsize, dpszpicx );
CardinalToString( pictureinfo.StartY, 3, str ); (* y co-ord *)
GemObjects.SetTEDData( dpsize, dpszpicy, str );
GemObjects.DeselectObject( dpsize, dpszpicy );
CardinalToString( pictureinfo.Width, 3, str ); (* width *)
GemObjects.SetTEDData( dpsize, dpszpicw, str );
GemObjects.DeselectObject( dpsize, dpszpicw );
CardinalToString( pictureinfo.Height, 3, str ); (* Height *)
GemObjects.SetTEDData( dpsize, dpszpich, str );
GemObjects.DeselectObject( dpsize, dpszpich );
END PictureImageToDialog;
(*----------------------------------------------------------------------*)
(* Picture info from dialog to picture image record. Hilight errors *)
(*----------------------------------------------------------------------*)
PROCEDURE DialogToPictureImage ( VAR pictureinfo : PictureImage;
VAR errormsg : ARRAY OF CHAR ) : BOOLEAN;
(* true = ok *)
VAR str : String;
done, error : BOOLEAN;
i : CARDINAL;
BEGIN
error := FALSE;
errormsg[0] := 0C;
GemObjects.GetTEDData( dpsize , dpszpicx, str );
IF NOT StringToCardinal( 0, 640, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszpicx );
IF errormsg[0] = 0C THEN
Assign('Pic: x ( 0 ..640 )', errormsg);
END;
ELSE
pictureinfo.StartX := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszpicy, str );
IF NOT StringToCardinal( 0, 400, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszpicy );
IF errormsg[0] = 0C THEN
Assign( 'Pic: y ( 0 ..400 ) ', errormsg);
END;
ELSE
pictureinfo.StartY := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszpicw, str );
IF NOT StringToCardinal( 0, 640, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszpicw );
IF errormsg[0] = 0C THEN
Assign( 'Pic: width (0 .. 640)', errormsg);
END;
ELSE
pictureinfo.Width := INTEGER(i);
END; (* if *)
GemObjects.GetTEDData( dpsize, dpszpich, str );
IF NOT StringToCardinal( 0, 400, str, i ) THEN
error := TRUE;
GemObjects.SelectObject( dpsize, dpszpich );
IF errormsg[0] = 0C THEN
Assign( 'Pic: height (0 .. 400)', errormsg);
END;
ELSE
pictureinfo.Height := INTEGER(i);
END; (* if *)
IF NOT error THEN
IF pictureinfo.StartX + pictureinfo.Width > HiResMaxX THEN
pictureinfo.Width := HiResMaxX + 1 - pictureinfo.StartX
END; (* if *)
IF pictureinfo.StartY + pictureinfo.Height > HiResMaxY THEN
pictureinfo.Height := HiResMaxY + 1 - pictureinfo.StartY
END; (* if *)
END; (* if error *)
RETURN NOT error;
END DialogToPictureImage;
(*----------------------------------------------------------------------*)
(* Run dialog to get print/picture image details from the user *)
(*----------------------------------------------------------------------*)
PROCEDURE DoImageDialog ( VAR picimage : PictureImage;
VAR prtimage : PrintImage );
VAR SavePicImage : PictureImage;
SavePrtImage : PrintImage;
dTree : ADDRESS ;
x, y, w, h, dumc : CARDINAL ;
result : INTEGER;
i : INTEGER;
errptr : StringPtr;
errmsg : ARRAY [ 0 .. 25 ] OF CHAR;
BEGIN
FOR i := 0 TO HIGH(errmsg) DO errmsg[i]:= ' ' END;
errmsg[HIGH(errmsg)] := 0C;
errptr := GemObjects.GetObjectSpec(dpsize, dpszerrm);
Assign(errmsg,errptr^);
SavePicImage := picimage;
SavePrtImage := prtimage;
PrintImageToDialog(prtimage);
PictureImageToDialog(picimage);
dTree := GemObjects.TreePointer( dpsize );
Forms.form_center(dTree, x, y, w, h) ;
dumc := Forms.form_dial(ReserveSpace, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(ExpandBox, 0, 0, 0, 0, x, y, w, h) ;
LOOP
GemObjects.DeselectObject(dpsize, dpszok) ;
GemObjects.DeselectObject(dpsize, dpszcan) ;
dumc := Object.objc_draw(dTree, 0, 10, x, y, w, h) ;
result := Forms.form_do( dTree, dpszpicx );
IF result = dpszcan THEN
picimage := SavePicImage;
prtimage := SavePrtImage;
EXIT;
END; (* if *)
IF DialogToPictureImage( picimage, errmsg ) THEN
IF DialogToPrintImage( prtimage, errmsg ) THEN
EXIT (* all ok *)
ELSE
Assign(errmsg,errptr^);
END; (* if *)
ELSE
Assign(errmsg,errptr^);
END; (* if *)
END; (* loop *)
dumc := Forms.form_dial(ShrinkBox, 0, 0, 0, 0, x, y, w, h) ;
dumc := Forms.form_dial(FreeSpace, 0, 0, 0, 0, x, y, w, h) ;
END DoImageDialog;
END DCDPrintImage.